/*
 * Middleware
 * Copyright (C) 2010/11
 * Riccardo Pulvirenti, Giuseppe Ravidà, Andrea Tino
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANDABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses
 */

/*!
 * File: workerdescriptor_proxy_factory.hpp
 */

#ifndef _WORKERDESCRIPTOR_PROXY_FACTORY_HPP_
#define _WORKERDESCRIPTOR_PROXY_FACTORY_HPP_

#include <iostream>
#include <string>

#include "workerdescriptor_manager_proxy.hpp"

//-----------------------------------------------------------------------------
// Class definitions
namespace middleware {
/*! \class WorkerDescriptorProxyFactory
 * \brief Manages WorkerDescriptorManagerProxy instantiation.
 *
 * This class represents the factory for WorkerDescriptorManagerProxy.
 */
class WorkerDescriptorProxyFactory {
public:
	/*!
	 * Constructs a factory providing parameters to correctly set the
	 * final proxy in order to listen for incoming WorkerDescriptor.
	 * \param bind_ip Ip v4 address where the final proxy will bind in order
	 * to listen for incoming WorkerDescriptor.
	 * \param bind_ip TCP Port where the final proxy will bind in order
	 * to listen for incoming WorkerDescriptor.
	 */
	WorkerDescriptorProxyFactory(std::string bind_ip, std::string bind_port);
	/*!
	 * Destructor.
	 */
	~WorkerDescriptorProxyFactory();
	/*!
	 * Gets proxy: attention, a new instance is created via dynamic allocation.
	 * If a previous proxy was generated, it will be detroyed.
	 */
	WorkerDescriptorManagerProxy* getProxy();
private:
	/*!
	 * Holds built proxy. If the factory is detroyed, then so is the proxy.
	 */
	WorkerDescriptorManagerProxy* _proxy;
	/*!
	 * Configuration parameter: Ip to bind to listen to worker descriptors.
	 */
	std::string _bind_ip;
	/*!
	 * Configuration parameter: Port to bind to listen to worker descriptors.
	 */
	std::string _bind_port;
}; /* WorkerDescriptorProxyFactory */
} /* middleware */

#endif
